<?php
class dbnamec extends CI_Controller{
	public function add(){
		//表单验证
		$this->load->library('form_validation');
		//定义验证规则
		#_form_rules;
		//验证
		if($this->form_validation->run() === FALSE){
			$this->load->view('admin/dbname/add');
		}else{
			//生成模型
			$this->load->model('dbnamem');
			$this->dbnamem->addData();
			redirect(site_url('admin/dbnamec/lst'));
		}
	}

	public function lst(){
		$this->load->model('dbnamem');
		$datas=$this->dbnamem->search();
		$this->load->view('admin/dbname/list',$datas);
	}

	public function delete($id){
		$this->load->model('dbnamem');
		$this->dbnamem->delete($id);
		redirect(site_url('admin/dbnamec/lst'));
	}

	public function save($id){
		//生成模型
		$this->load->model('dbnamem');
		/*获取修改的数据*/
		$info=$this->dbnamem->find($id);
		//表单验证
		$this->load->library('form_validation');
		//定义验证规则
		#_form_rules;
		//验证
		if($this->form_validation->run() === FALSE){
			$this->load->view('admin/dbname/save',$info);
		}else{
			$this->dbnamem->updateData();
			redirect(site_url('admin/dbnamec/lst'));
		}
	}

}